﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.ObjectFactory;
using System.Diagnostics.Contracts;

namespace YasharEl.Infrastructure.ApplicationModel.Modularity
{
    [ContractClass(typeof(ModuleContract))]
    public interface IModule
    {
        void Initialize(BaseDependencyContainer container, string moduleName, string configFile);

        void Run();

        void Shutdown();

        string ModuleName { get; }
    }

    [ContractClassFor(typeof(IModule))]
    internal abstract class ModuleContract : IModule
    {
        public void Initialize(BaseDependencyContainer container, string moduleName, string configFile)
        {
            Contract.Requires<ArgumentNullException>(container != null, "container could not be null.");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(moduleName), "moduleName could not be null or empty.");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(configFile), "configFile could not be null or empty.");
        }

        public void Run()
        {
        }

        public void Shutdown()
        {
        }

        public string ModuleName
        {
            get { return default(string); }
        }
    }
}
